package dancrawler.server;

import dancrawler.proto.cmd.CmdHandlerRegister;
import dancrawler.server.gamecmd.ServerCmdRegister;
import java.io.IOException;

/**
 *
 */
public class Gameserver {
    private GameHandler gh;
    private Server server;
    public Gameserver()
    {
        CmdHandlerRegister hreg = new CmdHandlerRegister();
        GameObjectRegister reg = new GameObjectRegister();
        server = new Server(hreg);
        gh = new GameHandler(null, server, reg,hreg);
        Gameworld gw = new WorldGenerator(reg, gh,1);
        
        
        gh.setTopLevel(gw);
        
        
        
        server.setGameHandler(gh);
        ServerCmdRegister.registerHandlers(hreg, gh);
        
        
        
        
    }
    public void start() throws IOException
    {
        gh.start();
        server.startServer();
    }
    public void stop()
    {
        server.stopServer();
        gh.StopGame();
    }
}
